{extend name="base/main" /}
{block name="body"}
<link rel="stylesheet" href="/static/layui/css/layui.css">
<script src="/static/layui/layui.js"></script>
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>分类管理 / 添加子分类</h5>
            </div>
            <div class="ibox-content">
                <form id="f" action="{:url('Classify/reades')}" class="form-horizontal m-t">
                 <div class="form-group">
                   <label class="col-sm-2 control-label">分类选择：</label>
                   <div class="col-sm-4">
                       <select name="pid" class="form-control" style="width: 200px">
                        <option value="">请选择</option>
                        {foreach $list as $key=>$vo}
                        <option value="{$vo.id}" name=""<?php if($vo['id']==$data['pid']){echo "selected";} ?>>{$vo.name}</option>
                        {/foreach}
                   </select>
                   </div>
                   </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">分类名称：</label>
                        <div class="col-sm-4">
                            <input name="name" value="{$data.name}" class="form-control" type="text">
                            <span class="help-block m-b-none Validform_checktip" ><i class="fa fa-info-circle"></i> 关于创建角色的名称</span>
                        </div>
                    </div>
                      <div class="form-group">
                    <div class="layui-upload">
                        <label class="col-sm-2 control-label">图标：</label>
                        <div class="col-sm-4">
                            <button type="button" class="layui-btn" id="test1">上传图片</button>
                            <div class="layui-upload-list">
                                <img class="layui-upload-img" id="demo1" width="100px" height="100px" src="{$data.img}">
                                <input type="hidden" name="img" id="img">
                                <p id="demoText"></p>
                            </div>
                        </div>
                    </div>
                </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">排序：</label>
                        <div class="col-sm-4">
                            <input name="sort" value="{$data.sort}" class="form-control" type="number" >
                            <span class="help-block m-b-none Validform_checktip" ><i class="fa fa-info-circle"></i> 关于创建角色的名称</span>
                        </div>
                    </div>
                      <div class="form-group">
                            <label class="col-sm-2 control-label">状态：</label>
                            <div class="col-sm-4">
                               <div class="radio i-checks" style="height: 60px;">
                                <input type="radio" value="1" name="status" <?php if($data['status']==1){echo "checked";} ?>><i></i>显示
                                <input type="radio" value="2" name="status" <?php if($data['status']==2){echo "checked";}?>><i></i>不显示
                             </div>
                            </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-4 col-sm-offset-3">
                             <input type="hidden" name="id" value="{$data.id}">
                            <button class="btn btn-primary" type="submit">提交</button>
                            <button class="btn btn-default historygo" type="button">返回</button>
                        </div>
                    </div>
                </form>
            </div>
                
        </div>
    </div>
    <script>
layui.use(['upload', 'element', 'layer'], function(){
  var $ = layui.jquery
  ,upload = layui.upload
  ,element = layui.element
  ,layer = layui.layer;
  
  //常规使用 - 普通图片上传
  var uploadInst = upload.render({
    elem: '#test1'
    ,url: '{:url('Classify/upload')}' //改成您自己的上传接口
    ,before: function(obj){
      //预读本地文件示例，不支持ie8
      obj.preview(function(index, file, result){
        $('#demo1').attr('src', result); //图片链接（base64）
      });
      
      element.progress('demo', '0%'); //进度条复位
      layer.msg('上传中', {icon: 16, time: 0});
    }
    ,done: function(res){
      //如果上传失败
      if(res.code > 0){
        return layer.msg('上传失败');
      }else{
         $('#img').val(res.data);
         return layer.msg('上传成功');
      }
      //上传成功的一些操作
      //……
      $('#demoText').html(''); //置空上传失败的状态
    }
    ,error: function(){
      //演示失败状态，并实现重传
      var demoText = $('#demoText');
      demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
      demoText.find('.demo-reload').on('click', function(){
        uploadInst.upload();
      });
    }
    //进度条
    ,progress: function(n, elem, e){
      element.progress('demo', n + '%'); //可配合 layui 进度条元素使用
      if(n == 100){
        layer.msg('上传完毕', {icon: 1});
      }
    }
  });
});
</script>
{/block}